/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-12-15 10:56:58
 * 天凉好个秋
 */

import type { App } from 'vue';
import type { I18n, I18nOptions } from 'vue-i18n'
import { createI18n } from 'vue-i18n'		//引入vue-i18n组件
import en from './en'
import zh_CN from './zh_CN';

export let i18n: ReturnType<typeof createI18n>;

const i18nOptions = {
    legacy: false,
    locale: localStorage.getItem('lang') || 'zh_CN',
    fallbackLocale: "zh_CN",
    messages: {
      en: en.message,
      zh_CN: zh_CN.message
    },
    sync: true, //If you don’t want to inherit locale from global scope, you need to set sync of i18n component option to false.
    silentTranslationWarn: true, // true - warning off
    missingWarn: false,
    silentFallbackWarn: true,
}
 
 
// setup i18n instance with glob
export async function setupI18n(app: App) {
    i18n = createI18n(i18nOptions as unknown as I18nOptions) as I18n;
    app.use(i18n);
  }